package com.daodao.daodaoschedule.infrastructure.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author mal
 * @date 2022-11-15 16:48
 */
@Configuration
public class JWTConfiguration {

    @Autowired
    private CustAccessTokenConverter custAccessTokenConverter;

    @Bean
    TokenStore tokenStore() {
        return new JwtTokenStore(jwtAccessTokenConverter());
    }

    @Bean
    JwtAccessTokenConverter jwtAccessTokenConverter() {
        JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
        tokenConverter.setAccessTokenConverter(custAccessTokenConverter);
        tokenConverter.setSigningKey("daodao");
        return tokenConverter;
    }
}
